/* Terminal Component Styles */

.terminal {
  flex: 1;
  min-width: 0; /* 允许flex子项收缩 */
  height: 100%;
  background: var(--color-terminal-bg);
  border-left: 1px solid var(--color-terminal-border);
  display: flex;
  flex-direction: column;
  min-height: 0; /* 确保能够收缩 */
  transition: all var(--transition-normal);
  /* 确保在桌面端不会溢出 */
  max-height: 100%;
  overflow: hidden;
}

.terminalHidden {
  flex: 0;
  min-width: 0;
  width: 0;
  overflow: hidden;
  border-left: none;
}

.terminalHeader {
  flex-shrink: 0; /* 防止标题被压缩 */
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--color-terminal-header);
  border-bottom: 1px solid var(--color-terminal-border);
  font-weight: 600;
  font-size: 14px;
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.terminalTitle {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.terminalIcon {
  font-size: 16px;
}

.terminalControls {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
}

.terminalControlBtn {
  padding: var(--spacing-xs);
  border: none;
  background: transparent;
  color: var(--color-text-tertiary);
  cursor: pointer;
  border-radius: var(--border-radius-sm);
  transition: all var(--transition-fast);
}

.terminalControlBtn:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.terminalContent {
  flex: 1;
  overflow-y: auto;
  padding: var(--spacing-md);
  font-family: var(--font-family-mono);
  font-size: 13px;
  line-height: 1.5;
  background: var(--color-terminal-bg);
  position: relative;
}

.terminalContent:empty::before {
  content: "运行代码查看输出结果...";
  color: var(--color-text-muted);
  font-style: italic;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* 滚动条样式 */
.terminalContent::-webkit-scrollbar {
  width: 8px;
}

.terminalContent::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
  border-radius: var(--border-radius-sm);
}

.terminalContent::-webkit-scrollbar-thumb {
  background: var(--color-border-secondary);
  border-radius: var(--border-radius-sm);
  border: 2px solid var(--color-bg-secondary);
}

.terminalContent::-webkit-scrollbar-thumb:hover {
  background: var(--color-text-tertiary);
}

/* 输出内容样式 */
.normalOutput {
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--color-text-primary);
  min-height: 1.5em;
  line-height: 1.5;
}

/* 输入行输出样式 */
.inputLineOutput {
  white-space: pre-wrap;
  word-wrap: break-word;
  color: var(--color-text-primary);
  font-family: var(--font-family-mono);
  font-size: 13px;
  min-height: 1.5em;
  line-height: 1.5;
  background: var(--color-bg-secondary);
  padding: 2px 4px;
  border-radius: 3px;
  margin: 1px 0;
}

/* 错误消息样式 */
.inlineError {
  margin: var(--spacing-sm) 0;
  padding: var(--spacing-md);
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-left: 4px solid #ef4444;
  border-radius: var(--border-radius-md);
  font-family: var(--font-family-mono);
}

.inlineErrorHeader {
  font-weight: 600;
  color: #ef4444;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--spacing-xs);
}

.inlineErrorContent {
  color: var(--color-text-primary);
  font-size: 13px;
}

.errorLocation {
  color: #dc2626;
  font-weight: 600;
  margin-right: var(--spacing-xs);
}

.errorMessage {
  color: var(--color-text-primary);
}

/* 警告消息样式 */
.inlineWarning {
  margin: var(--spacing-sm) 0;
  padding: var(--spacing-md);
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  border-left: 4px solid #f59e0b;
  border-radius: var(--border-radius-md);
  font-family: var(--font-family-mono);
}

.inlineWarningHeader {
  font-weight: 600;
  color: #f59e0b;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--spacing-xs);
}

.inlineWarningContent {
  color: var(--color-text-primary);
  font-size: 13px;
}

/* 系统消息样式 */
.inlineSystem {
  margin: var(--spacing-sm) 0;
  background: transparent;
  padding: var(--spacing-md) var(--spacing-lg);
  text-align: center;
  font-family: var(--font-family-sans);
  font-size: 14px;
  font-weight: 500;
  position: relative;
}

.inlineSystemMessage {
  color: var(--color-text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  font-weight: 600;
  letter-spacing: 0.025em;
  flex-wrap: wrap;
}

.iconTitle {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  font-size: 15px;
}

.systemIcon {
  font-size: 16px;
}

.systemTitle {
  font-weight: 600;
}

.timeContainer {
  display: flex;
  gap: var(--spacing-lg);
  margin-left: var(--spacing-lg);
  align-items: center;
}

.durationSection,
.timestampSection {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) var(--spacing-sm);
  background: transparent;
}

.timeIcon {
  font-size: 16px;
  opacity: 0.9;
}

.timeLabel {
  font-size: 11px;
  color: var(--color-text-tertiary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-right: 2px;
}

.durationBadge {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
  color: white;
  padding: 3px 10px;
  border-radius: 10px;
  font-family: var(--font-family-mono);
  font-weight: 800;
  font-size: 12px;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  min-width: 45px;
  text-align: center;
}

.timestampBadge {
  background: var(--color-bg-tertiary);
  color: var(--color-text-secondary);
  padding: 3px 8px;
  border-radius: 10px;
  font-family: var(--font-family-mono);
  font-weight: 700;
  font-size: 11px;
  min-width: 75px;
  text-align: center;
}

/* 桌面端确保正常flex布局 */
@media (min-width: 769px) {
  .terminal {
    /* 确保在桌面端正常的flex布局 */
    position: static;
    z-index: auto;
    /* 重置所有可能影响布局的属性 */
    top: auto;
    bottom: auto;
    left: auto;
    right: auto;
    transform: none;
  }
}

/* 移动端响应式设计 */
@media (max-width: 768px) {
  .terminal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40vh;
    z-index: 100;
    border-left: none;
    border-top: 1px solid var(--color-terminal-border);
    /* 确保不会遮挡顶部区域，为toolbar(48px)和filebar(36px)留出空间 */
    max-height: calc(100vh - 84px);
  }
  
  .terminalHidden {
    transform: translateY(100%);
    height: 0;
  }
  
  .terminalHeader {
    padding: var(--spacing-sm) var(--spacing-md);
  }
  
  .terminalContent {
    padding: var(--spacing-sm);
    font-size: 12px;
  }
  
  .inlineSystem {
    padding: var(--spacing-sm) var(--spacing-md);
    margin: var(--spacing-xs) 0;
  }
  
  .inlineSystemMessage {
    flex-direction: column;
    gap: var(--spacing-sm);
    align-items: flex-start;
  }
  
  .iconTitle {
    font-size: 14px;
    gap: var(--spacing-xs);
    align-self: center;
  }
  
  .timeContainer {
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-left: 0;
    align-self: center;
    width: 100%;
  }
  
  .durationSection,
  .timestampSection {
    padding: 3px 6px;
    gap: var(--spacing-xs);
    justify-content: center;
  }
  
  .timeLabel {
    font-size: 10px;
    letter-spacing: 0.3px;
  }
  
  .durationBadge {
    font-size: 11px;
    padding: 2px 8px;
    min-width: 40px;
  }
  
  .timestampBadge {
    font-size: 10px;
    padding: 2px 6px;
    min-width: 70px;
  }
  
  .timeIcon {
    font-size: 14px;
  }
}

@media (max-width: 480px) {
  .inlineSystem {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: 13px;
  }
  
  .iconTitle {
    font-size: 13px;
  }
  
  .timeContainer {
    gap: var(--spacing-xs);
  }
  
  .durationSection,
  .timestampSection {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 3px;
    padding: 2px 4px;
  }
  
  .timeLabel {
    font-size: 9px;
  }
  
  .durationBadge {
    font-size: 10px;
    padding: 1px 6px;
    min-width: 35px;
  }
  
  .timestampBadge {
    font-size: 9px;
    padding: 1px 4px;
    min-width: 65px;
  }
  
  .timeIcon {
    font-size: 12px;
  }
}

/* 输入行样式 */
.inputLine {
  display: flex;
  align-items: center;
  gap: 0;
  line-height: 1.5;
  margin: 0;
  padding: 0;
}

.inputPrompt {
  color: var(--color-text-primary);
  font-family: var(--font-family-mono);
  font-size: 13px;
  white-space: nowrap;
  flex-shrink: 0;
}

.inputField {
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text-primary);
  font-family: var(--font-family-mono);
  font-size: 13px;
  padding: 0;
  margin: 0;
  resize: none;
  overflow: hidden;
  caret-color: #3b82f6;
  line-height: 1.5;
  min-width: 200px;
  height: 1.5em;
  flex: 1;
}



/* 响应式输入行样式 */
@media (max-width: 768px) {
  .inputPrompt {
    font-size: 12px;
  }
  
  .inputField {
    font-size: 12px;
    min-width: 150px;
  }
}

@media (max-width: 480px) {
  .inputPrompt {
    font-size: 11px;
  }
  
  .inputField {
    font-size: 11px;
    min-width: 100px;
  }
}
